import { electronApp } from '@electron-toolkit/utils';
import { addCommandLineParams, loadDevtools } from './devtool';
import { addToRegistry, readProtocol } from './registry';
import { appId } from '../../common/configs/build-const';
import { createMainWindow } from '../windows/main-window';
import { bindInitEvent, sendWebContentsEvent } from './event';
import { setupStore } from '../utils/store';
import { setupFFprobe } from '../utils/ffprobe';
import { initShortcut } from './shortcut';
import '../utils/logger';

export function frontInit() {
  addCommandLineParams();
  addToRegistry();
  bindInitEvent();
  setupStore();
  setupFFprobe();
}

export function appReadyInit() {
  electronApp.setAppUserModelId(appId);
  loadDevtools();
  initShortcut();
  const mainWindow = createMainWindow();
  const customUrl = readProtocol(process.argv);
  if (customUrl) {
    sendWebContentsEvent(mainWindow.webContents, 'rc:enter-protocol-data', customUrl);
  }
}
